<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>JSTL</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <c:out value="${username}" default="jqb"></c:out>pa<br>
    <c:out value="${username}" >jqb</c:out><br>
    <%session.setAttribute("html","<h1>xxxx</h1>"); %><br>
    <c:out value="${html}" /><br>
    <c:out value="${html}" escapeXml="false"/><br>
    <c:out value="==============分割线=============="/><br><br>
    <c:set value="jqblizzie" var="name"/>
    <c:out value="${name}"/><br>
    <c:out value="==============分割线=============="/><br><br>
    <c:set value="jqblizzie" var="myname" scope="session"/>
    before remove: <c:out value="${myname}"/><br>
    <c:remove var="myname" scope="session"/>
    after remove: <c:out value="${myname}"/><br>
    <c:out value="==============分割线=============="/><br><br>
    <c:catch var="ex">
    <%int x=10/0; %>
    </c:catch>
    <c:out value="${ex}"/><br>
    <c:if test="${sessionScope.username=='jqbxxx'}" var="result">
    	<c:out value="welcome!"/>
    </c:if>
    <c:out value="${result}"></c:out><br>
    <c:set var="username" value="jqb" scope="session"></c:set>
    <c:if test="${sessionScope.username=='jqb'}" var="result">
     	<c:out value="welcome!"/>
    </c:if>
    <c:out value="${result}"></c:out><br>
    <c:out value="==============分割线=============="/><br><br>
    <c:choose>
    	<c:when test="${param.age>70}">
    		<c:out value="欢迎老人！"/>
    	</c:when>
    	<c:when test="${param.age>=35 and param.age<=70}">
    		<c:out value="欢迎中年人！"/>
    	</c:when>
    	<c:when test="${param.age<35 and param.age>0}">
    		<c:out value="欢迎年轻人！"/>
    	</c:when>
    	<c:otherwise>
    		<c:out value="你还没出生呢！"/>
    	</c:otherwise>
    </c:choose><br>
    <c:out value="==============分割线=============="/><br><br>
    <%
    	String[] names=new String[4];
   	 	names[0]="111";
   	 	names[1]="222";
   	 	names[2]="333";
   	 	names[3]="444";
   	 	pageContext.setAttribute("names",names);
    %>
    <c:forEach items="${names}" var="name" begin="0" end="3" step="1" varStatus="i">
    	name[${i.index}]=${name}<br>
    	\${i.count }=${i.count }<br><%//获取当前是第几次循环 %>
    	\${i.first }=${i.first }<br><%//判断当前是否是第1次循环 %>
    	\${i.last }=${i.last }<br><%//判断当前是否是最后次循环 %>
    </c:forEach><br>
    <%
    	ArrayList names1=new ArrayList();
   	 	names1.add("111");
   	 	names1.add("222");
   	 	names1.add("333");
   	 	names1.add("444");
   	 	pageContext.setAttribute("names1",names1);
    %>
    <c:forEach items="${names1}" var="name" begin="0" end="3" step="1" varStatus="i">
    	${name}<br>
    	
    </c:forEach><br>
    <%
    	Map names2=new HashMap();
    	names2.put("aaa","111");
   	 	names2.put("bbb","222");
   	 	names2.put("ccc","333");
   	 	names2.put("ddd","444");
   	 	pageContext.setAttribute("names2",names2);
    %> 
    <c:forEach items="${names2}" var="name" begin="0" end="3" step="1" varStatus="i">
    	${name.key }:
    	${name.value }<br>
    </c:forEach><br>
    <c:out value="==============分割线=============="/><br><br>
    <c:forTokens items="A:B:C:D:E" delims=":" var="name">
    ${name }
    </c:forTokens><br>
    <c:out value="==============分割线=============="/><br><br>
    <c:import url="http://www.google.cn"/><br>
    <c:out value="==============分割线=============="/><br><br>
    <c:url value="http://www.google.cn" var="google">
   		<c:param name="a" value="Terry"></c:param>
   		<c:param name="b" value="John"></c:param>
    </c:url>
    <c:out value="${google}"></c:out><br>
    <a href="${google }">google</a><br>
    <c:out value="==============分割线=============="/><br><br>

  </body>
</html>
